<template>
  <div class="login">
    <div class="lg-left">
      <h3 class="lg-title">用户登录</h3>
      <form action="">
        <div class="lg-item lg-tel">
          <input
            type="text"
            class="ipt-tel"
            placeholder="手机号/学号"
            id="phone"
            maxlength="50"
            v-model="account"
          />
        </div>
        <div class="lg-item lg-pwd">
          <input
            :type="pwdFlag ? 'password' : 'text'"
            name=""
            id=""
            placeholder="登录密码"
            v-model="password"
          />
          <img
            :src="pwdFlag ? eyeClose : eyeOpen"
            alt=""
            @click="changePwd"
            class="icon-eye"
          />
        </div>
        <div class="btn-box">
          <button type="button" class="lg-btn" @click="Login()">登录</button>
        </div>
      </form>
      <div class="lg-pd">
        <a href="javaScript:void(0)" class="col-fl col-com">新用户注册</a>
        <a href="javaScript:void(0)" class="col-fr col-com">忘记密码</a>
      </div>
      <div class="line">
        <a href="javaScript:void(0)" class="col-light">其他方式登录</a>
      </div>
      <p class="Agreement">登录即表示同意平台协议</p>
    </div>
    <div class="right">
      <div class="step">
        <img src="../assets/login.png" alt="" />
      </div>
      <p class="col-tip">网络教学系统</p>
    </div>
  </div>
</template>
<script>
import { postLogin } from "@/api/api";
import VAR from "@/api/global_var";
import * as types from "../store/types";
export default {
  data() {
    return {
      account: "",
      password: "",
      pwdFlag: false,
    };
  },
  methods: {
    eyeOpen() {},
    changePwd() {},

    Login() {
      var params = {
        phoneNum: this.account,
        passWd: this.password,
        lastTime: VAR.getDate(new Date()),
        lastIp: localStorage.Ip,
      };
      postLogin(params).then((res) => {
        if (res.status === 200) {
          this.$store.commit(types.LOGIN, JSON.stringify(res.data));
          this.$router.push({
            name: "My",
          });
        }
      });
    },
  },
};
</script>

<style scoped>
a {
  text-decoration: none;
}
.login {
  width: 900px;
  height: 584px;
  overflow: hidden;
  box-shadow: 0 0 20px 0 rgb(175 187 204 / 15%);
  background: #ffffff;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-border-radius: 16px;
  -moz-border-radius: 16px;
  border-radius: 16px;
  position: fixed;
  left: 20%;
  top: 15%;
  min-height: 555px;
}
.lg-left {
  width: 450px;
  margin: 90px;
}
form {
  display: block;
  width: 360px;
}
.lg-title {
  color: #181e33;
  font-size: 20px;
  margin-bottom: 44px;
  font-weight: normal;
  width: 360px;
}

.lg-item {
  margin-bottom: 34px;
  position: relative;
}
.lg-item input {
  width: 100%;
  height: 48px;
  vertical-align: top;
  background: #ffffff;
  border: 1px solid #e3e8f0;
  outline: none;
  font-size: 14px;
  color: #181e33;
  -webkit-border-radius: 24px;
  border-radius: 24px;
  padding: 0 24px 0 54px;
  box-sizing: border-box;
}
.ipt-tel:before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  background: url(../assets/icon-tel.png) no-repeat center;
  background-size: cover;
  vertical-align: middle;
  position: absolute;
}
.icon-eye {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 18px;
  height: 18px;

  background-size: cover;
}
.btn-box {
  position: relative;
}
.lg-btn {
  width: 360px;
  height: 48px;
  background-color: #4587c5;
  background-size: cover;
  box-shadow: 0 3px 12px 0 rgb(39 125 255 / 30%);
  border-radius: 24px;
  font-size: 18px;
  color: #ffffff;
  outline: none;
  margin: 20px 0px;
  cursor: pointer;
  border: none;
}
.lg-pd {
  padding: 0 24px;
  width: 314px;
  height: 21px;
}
.col-com {
  color: #3a8bff;
  font-size: 14px;
}
.col-fl {
  float: left;
}
.col-fr {
  float: right;
}
.lg-pd:after {
  content: "";
  display: block;
  clear: both;
}
.line {
  margin-top: 20px;
  border-top: 1px dashed #f2f2f2;
  padding-top: 24px;
  box-sizing: border-box;
  padding-left: 140px;
}
.col-light {
  color: #91a0b5;
  font-size: 14px;
}
.line:after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 10px;
  background: url(../assets/icon-right.png) no-repeat center;
  background-size: cover;
  margin-left: 5px;
}
.Agreement {
  box-sizing: border-box;
  padding-left: 120px;
  font-size: 12px;
  color: #a8a8b3;
  position: relative;
  left: 0px;
  bottom: -40px;
}
.right {
  height: 100%;
  width: 360px;
  padding: 155px 64px 0;
  border-left: 1px dashed #f2f2f2;
  text-align: center;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
}
.step {
  height: 231px;
  width: 236px;
  border: 1px solid #f2f2f2;
  -webkit-border-radius: 12px;
  -moz-border-radius: 12px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.step img {
  width: 100%;
  height: 100%;
}
.col-tip {
  margin-bottom: 40px;
  font-weight: 400;
  color: #646873;
  font-size: 14px;
}
</style>